package mode.strategy;

/**
 * 订单服务实现类
 *
 * @author xjx
 * @date 2023/7/31 10:39
 */
public class Order {
    private String uid;
    private double amount;

    public Order(String uid, double amount) {
        this.uid = uid;
        this.amount = amount;
    }

    public String pay() {
        return pay("cash");
    }
    public String pay(String key) {
        Payment payment =(Payment) PaymentStrategy.getPayService(key);
        System.out.println("欢迎使用" + payment.getPaymentName());
        System.out.println("本次交易金额:" + this.amount + ",开始扣款...");
        return payment.pay(this.uid, this.amount);
    }
}
